package com.jinlejia.bbs.dialog;

import android.app.Dialog;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

import com.jinlejia.bbs.R;
import com.jinlejia.bbs.databinding.BbsDialogContributeResultBinding;

/**
 * @author 王进 on 2019/3/6.
 */

public class ContributeResultDialog extends DialogFragment {

    @Override
    public void onStart() {
        Dialog dialog = getDialog();
        if (dialog!=null){
            DisplayMetrics dm = new DisplayMetrics();
            getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
            Window window = getDialog().getWindow();
            window.setLayout((int) (dm.widthPixels * 0.75), ViewGroup.LayoutParams.WRAP_CONTENT);
        }
        super.onStart();
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.bbs_dialog_contribute_result, container);
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        BbsDialogContributeResultBinding binding = DataBindingUtil.bind(view);
        String content = "1、月度贡献达人排行是在一个月（自然月）内回答话题条数进行排名。\n"
//                + "2、规则，一般指由群众共同制定、公认或由代表人统一制定并通过的，由群体里的所有成员一起遵守的条例和章程。\n"
//                + "3、它存在三种形式：明规则、潜规则、元规则，无论何种规则只要违背善恶的道德必须严惩不贷以维护世间和额谐；明规则是有明文规定的的规则，存在需要不断。"
                ;
        binding.resultContent.setText(content);
        binding.closeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        return view;
    }
}
